package risk.control.project.api;


import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import risk.control.project.framework.PostController;
import risk.control.project.service.BranchService;
import risk.control.project.service.TakeRecordService;

import java.util.HashMap;


@RestController
@RequestMapping(value = "/main", produces = {"application/json;charset=UTF-8"})
public class MAIN_000_000_012 extends PostController {
    private static final Logger logger = LoggerFactory.getLogger(MAIN_000_000_012.class);

    private final TakeRecordService takeRecordService;

    //查询取现记录
    public MAIN_000_000_012(TakeRecordService takeRecordService) {
        this.takeRecordService = takeRecordService;
    }

    @PostMapping(value = "/000_000_012")
    public String doPost(HttpServletRequest request) {
        return handleRequest(request);
    }

    @Override
    protected String postRequest(HashMap<String, String> param) {
        String requestBody = param.get("requestBody");
        JSONObject jsonObject = (JSONObject) JSON.parse(requestBody);
        String pageSize = jsonObject.getString("pageSize");//每页展示多少条数据
        String pageIndex = jsonObject.getString("pageIndex");//第几页
        String startTime = jsonObject.getString("startTime");//开始时间
        String endTime = jsonObject.getString("endTime");//结束时间
        if (startTime == null || startTime.isEmpty() || endTime == null || endTime.isEmpty()) {
            return takeRecordService.record(pageSize, pageIndex);//默认查询
        }
        //条件查询-开始时间+结束时间
        return takeRecordService.queryRecordFromWithdrawalTime(startTime, endTime, pageSize, pageIndex);//默认查询
    }
}
